package com.scuec.groupfive.entity.vo;

import com.scuec.groupfive.entity.Post;
import com.scuec.groupfive.entity.PostComment;
import com.scuec.groupfive.entity.PostFavorite;
import lombok.Data;

import java.util.Date;
import java.util.List;

@Data
public class UserPostVO {
    // 帖子字段
    private Long postId;
    private Long userId;
    private String title;
    private String content;
    private Integer viewCount;
    private Integer status;
    private String tag;
    private Integer commentCount;
    private Integer likeCount;
    private Integer favoriteCount;
    private String username;
    private String avatar;
    private String userRole;
    private Date createdAt;
    private Date updatedAt;

    // 收藏字段
    private Long favoriteId;
    private Date favoriteCreatedAt;

    // 新增：评论列表
    private List<PostComment> comments;

    public UserPostVO(Post post, PostFavorite favorite, List<PostComment> comments) {
        // 设置帖子字段
        this.postId = post.getPostId();
        this.userId = post.getUserId();
        this.title = post.getTitle();
        this.content = post.getContent();
        this.viewCount = post.getViewCount();
        this.status = post.getStatus();
        this.tag = post.getTag();
        this.commentCount = post.getCommentCount();
        this.likeCount = post.getLikeCount();
        this.favoriteCount = post.getFavoriteCount();
        this.username = post.getUsername();
        this.avatar = post.getAvatar();
        this.userRole = post.getUserRole();
        this.createdAt = post.getCreatedAt();
        this.updatedAt = post.getUpdatedAt();

        // 设置收藏字段
        this.favoriteId = favorite.getFavoriteId();
        this.favoriteCreatedAt = favorite.getCreatedAt();

        // 设置评论列表
        this.comments = comments;
    }
}